package oj.common.core.controller;
import cn.hutool.core.collection.CollectionUtil;
import com.github.pagehelper.PageInfo;
import oj.common.core.domain.Result;
import oj.common.core.domain.TableDataInfo;

import java.util.List;

public class BaseController {
    public Result<Void> toResult(int operation) {
        return operation>0? Result.success():Result.failed();
    }
    public Result<Void> toResult(boolean operation) {
        return operation==true ? Result.success():Result.failed();
    }
    public TableDataInfo getTableDataInfo(List<?> list) {
        if(CollectionUtil.isEmpty(list)){
            return TableDataInfo.empty();
        }
        return TableDataInfo.success(list,new PageInfo<>(list).getTotal());
    }
}
